// const cloudbase = require("@cloudbase/node-sdk");

// const app = cloudbase.init({});
// // 1. 获取数据库引用
// const db = app.database();


// exports.main = async (event, context) => {
//   const res = await db
//     .collection("myuser")
//     .get()
//   return {
//     res
//   };
// };




// 云函数入口文件
const cloud = require('qq-server-sdk')

const got = require('got'); //引用 got

cloud.init({
    env: 'sex-0glappmfb779ea47'
})

// 云函数入口函数
exports.main = async (event, context) => {
    //let getResponse = await got('httpbin.org/get') //get请求 用httpbin.org这个网址做测试 
    //return getResponse.body
    let postResponse = await got('httpbin.org/post', {
        method: 'POST', //post请求
        headers: {
            'Content-Type': 'application/json'
        },
        body: JSON.stringify({
            touser: 'a3da4186311c4535bf7bd6e7551242d2',
            page: '/page/knowage/knowage',
            templateId: 'cf024dc1a2b94a8ece5aea6081b104fd',
            data: {
                keyword1: {
                    value: '我是玖柒后'
                },
                keyword2: {
                    value: 'Hello World!'
                },
                keyword3: {
                    value: "发送成功！"
                }
            },

        })
    })

    return postResponse.body //返回数据
}


